package com.cloud.business.controller.sys;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cloud.business.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.cloud.core.common.HttpContentResult;
import com.cloud.business.model.commonvm.DeletePost;
import com.cloud.business.model.commonvm.ResultMsg;

import com.cloud.business.model.sys.mapcoefficient.*;
import com.cloud.business.service.sys.ISysMapCoefficientService;
import com.cloud.business.entity.sys.SysMapCoefficient;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;

/**
 * 地图系数配置 API接口层
 * Copyright: Copyright (C) 2020 DLANGEL, Inc. All rights reserved.
 * Company: 大连安琪科技有限公司
 *
 * @author dh
 * @since 2020-10-12 02:53:20
 */
@Api(tags = "地图系数配置 模块")
@RestController
@RequestMapping("/api/sysMapCoefficient")
public class SysMapCoefficientController extends BaseController {

    @Resource
    private ISysMapCoefficientService sysMapCoefficientService;


    //region 获取分页列表

    /**
     * 获取分页列表
     *
     * @param queryModel
     * @return
     */
    @ApiOperation(value = "获取分页列表")
    @PostMapping("/getListByPage")
    public HttpContentResult getListByPage(@RequestBody SysMapCoefficientQueryModel queryModel) {
        try {
            queryModel.setOperationId(getOperationId());
            return sysMapCoefficientService.getListByPage(queryModel);
        } catch (Exception ex) {
            return HttpContentResult.errorResult(ex.getMessage());
        }
    }
    //endregion

    //region 创建

    /**
     * 创建
     *
     * @param post
     * @return
     * @author Rex
     */
    @ApiOperation(value = "创建")
    @PostMapping("/create")
    public HttpContentResult create(@RequestBody SysMapCoefficientPost post) {
        ResultMsg msg = new ResultMsg();
        try {
            post.setCreateUserId(getOperationId());
            Integer objectId = sysMapCoefficientService.create(post, msg);
            return HttpContentResult.successResult(msg.getMsg(), 1L, objectId);
        } catch (Exception ex) {
            return HttpContentResult.errorResult(ex.getMessage());
        }
    }
    //endregion

    //region 更新

    /**
     * 更新
     *
     * @param post
     * @return
     * @author Rex
     */
    @ApiOperation(value = "更新")
    @PostMapping("/update")
    public HttpContentResult update(@RequestBody SysMapCoefficientPost post) {
        ResultMsg msg = new ResultMsg();
        try {
            post.setModificationUserId(getOperationId());
            Integer objectId = sysMapCoefficientService.update(post, msg);
            return HttpContentResult.successResult(msg.getMsg(), 1L, objectId);
        } catch (Exception ex) {
            return HttpContentResult.errorResult(ex.getMessage());
        }
    }
    //endregion

    //region 获取单条

    /**
     * 获取单条
     *
     * @param objectId
     * @return
     */
    @ApiOperation(value = "获取单条")
    @GetMapping("/getById")
    public HttpContentResult getById(Integer objectId) {
        ResultMsg msg = new ResultMsg();
        try {
            Integer operationId = getOperationId();
            SysMapCoefficient model = sysMapCoefficientService.getById(operationId, objectId, msg);
            return HttpContentResult.successResult(msg.getMsg(), 1L, model);
        } catch (Exception ex) {
            return HttpContentResult.errorResult(ex.getMessage());
        }
    }
    //endregion

    //region 批量删除

    /**
     * 批量删除
     *
     * @param deletePost
     * @return
     * @author Rex
     */
    @ApiOperation(value = "批量删除")
    @PostMapping("/deleteByList")
    public HttpContentResult deleteByList(@RequestBody DeletePost deletePost) {
        ResultMsg msg = new ResultMsg();
        try {
            deletePost.setOperationId(getOperationId());
            Integer count = sysMapCoefficientService.deleteByList(deletePost, msg);
            return HttpContentResult.successResult(msg.getMsg(), 1L, count);
        } catch (Exception ex) {
            return HttpContentResult.errorResult(ex.getMessage());
        }
    }
    //endregion


}
